package br.com.itc.componentes.botoes
{
	import flash.events.KeyboardEvent;
	import flash.events.MouseEvent;
	import flash.ui.Keyboard;
	
	import mx.controls.Button;
	import mx.events.FlexEvent;
	
	public class Botao extends Button
	{
		public function Botao()
		{
			super();
			this.buttonMode = true;
			this.styleName = "buttonOfficial"; //nome de estilo
			this.addEventListener(FlexEvent.CREATION_COMPLETE, init);
		}
		
		private function init(event: FlexEvent): void {

			this.addEventListener(KeyboardEvent.KEY_DOWN, disparaEventoMouse);
		}
		
		private function disparaEventoMouse(event: KeyboardEvent): void {
			if (event.keyCode == Keyboard.ENTER || event.keyCode == Keyboard.BACKSPACE) {
				this.dispatchEvent(new MouseEvent(MouseEvent.CLICK));
			}
		}
	}
}